import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:meal/constant/fonts.dart';
import 'package:meal/constant/sizes.dart';
import 'package:meal/route/route.dart';
import 'package:meal/utils/colors.dart';
import 'package:meal/utils/styles.dart';
import 'package:meal/utils/tools.dart';

class FinanceManage extends StatefulWidget {
  const FinanceManage({Key? key}) : super(key: key);

  @override
  State<FinanceManage> createState() => _FinanceManageState();
}

class _FinanceManageState extends State<FinanceManage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: ToolsUtils.getDefaultBackgroundColor(),
      appBar: ToolsUtils.getDefaultBrnAppBar('财务管理'),
      body: SingleChildScrollView(
        child: Column(
          children: [
            Stack(
              children: [
                ClipPath(
                  ///路径裁切组件
                  clipper: _BottomClipper(),
                  child: Container(
                    color: ColorsUtils.rgba(255, 110, 83, 1),
                    height: 165.0,
                    child: Column(
                      children: [
                        Container(
                          height: Sizes.default35,
                          alignment: Alignment.center,
                          child: Text(
                            '账户余额',
                            style: StylesUtils.customTextStyle(fontSize: Sizes.default13),
                          ),
                        ),
                        Stack(
                          children: [
                            Container(
                              height: Sizes.default35,
                              alignment: Alignment.center,
                              child: Text(
                                '3289.07',
                                style: StylesUtils.customTextStyle(fontSize: Sizes.default28),
                              ),
                            ),
                            Positioned(
                                top: 0,
                                right: Sizes.default10,
                                bottom: 0,
                                child: Center(
                                  child: TextButton(
                                      onPressed: () {
                                        Get.toNamed(RouteGet.financeBalanceDetail);
                                      },
                                      child: Text(
                                        '明细',
                                        style:
                                            StylesUtils.customTextStyle(fontSize: Sizes.default13),
                                      )),
                                ))
                          ],
                        )
                      ],
                    ),
                  ),
                ),
                Positioned(
                  height: Sizes.default80,
                  bottom: 0,
                  left: Sizes.default20,
                  right: Sizes.default20,
                  child: Container(
                    padding: const EdgeInsets.only(
                        top: Sizes.default15,
                        bottom: Sizes.default10,
                        left: Sizes.default10,
                        right: Sizes.default10),
                    decoration: boxDecoration,
                    child: Row(
                      children: [
                        Expanded(
                            child: InkWell(
                              onTap: () {
                                Get.toNamed(RouteGet.financeWithdrawalAdd);
                              },
                              child: Column(
                                children: [
                                  Container(
                                    alignment: Alignment.center,
                                    child: ToolsUtils.getUrlImg(
                                        'https://cdn7.axureshop.com/demo/1525603/images/财务管理/u1832.png',
                                        width: 36,
                                        height: 25),
                                  ),
                                  Container(
                                    margin: const EdgeInsets.only(top: Sizes.default10),
                                    alignment: Alignment.center,
                                    child: Text(
                                      '提现',
                                      style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                                    ),
                                  )
                                ],
                              ),
                            )),
                        Expanded(
                            child: InkWell(
                              onTap: () {
                                Get.toNamed(RouteGet.financeTransferAccount);
                              },
                              child: Column(
                                children: [
                                  Container(
                                    alignment: Alignment.center,
                                    child: ToolsUtils.getAssetImageIcon('transfer.png',
                                        width: 36, height: 25),
                                  ),
                                  Container(
                                    margin: const EdgeInsets.only(top: Sizes.default10),
                                    alignment: Alignment.center,
                                    child: Text(
                                      '转账',
                                      style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                                    ),
                                  )
                                ],
                              ),
                            )
                        ),
                        Expanded(
                            child: InkWell(
                              onTap: () {
                                Get.toNamed(RouteGet.financeRechargeAdd);
                              },
                              child: Column(
                                children: [
                                  Container(
                                    alignment: Alignment.center,
                                    child: ToolsUtils.getUrlImg(
                                        'https://cdn7.axureshop.com/demo/1525603/images/财务管理/u1835.png',
                                        width: 36,
                                        height: 25),
                                  ),
                                  Container(
                                    margin: const EdgeInsets.only(top: Sizes.default10),
                                    alignment: Alignment.center,
                                    child: Text(
                                      '充值',
                                      style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                                    ),
                                  )
                                ],
                              ),
                            )
                        ),
                        Expanded(
                            child: InkWell(
                              onTap: () {
                                Get.toNamed(RouteGet.financeBankCardManage);
                              },
                              child: Column(
                                children: [
                                  Container(
                                    alignment: Alignment.center,
                                    child: ToolsUtils.getUrlImg(
                                        'https://cdn7.axureshop.com/demo/1525603/images/财务管理/u1838.png',
                                        width: 36,
                                        height: 25),
                                  ),
                                  Container(
                                    margin: const EdgeInsets.only(top: Sizes.default10),
                                    alignment: Alignment.center,
                                    child: Text(
                                      '银行卡',
                                      style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                                    ),
                                  )
                                ],
                              ),
                            )
                        ),
                      ],
                    ),
                  ),
                )
              ],
            ),
            Container(
              margin: const EdgeInsets.only(
                  left: Sizes.default20, right: Sizes.default20, top: Sizes.default20),
              decoration: boxDecoration,
              padding: const EdgeInsets.all(Sizes.default10),
              child: ListBody(
                children: [
                  Row(
                    children: [
                      Expanded(
                        flex: 2,
                        child: Align(
                          alignment: Alignment.centerRight,
                          child: ToolsUtils.getUrlSvg(
                              'https://cdn7.axureshop.com/demo/1525603/images/财务管理/u1826.svg',
                              width: 45,
                              height: 45),
                        ),
                      ),
                      Expanded(
                        flex: 5,
                        child: Container(
                          padding: const EdgeInsets.only(left: Sizes.default10),
                          child: Column(
                            children: [
                              Container(
                                alignment: Alignment.centerLeft,
                                child: Text(
                                  '0.00',
                                  style: StylesUtils.customTextStyle(
                                      color: ColorsUtils.colorFf6,
                                      fontSize: Sizes.default18,
                                      fontWeight: Fonts.w7),
                                ),
                              ),
                              Container(
                                margin: const EdgeInsets.only(top: Sizes.default10),
                                alignment: Alignment.centerLeft,
                                child: Text(
                                  '今日预计收入（订单数：0）',
                                  style: StylesUtils.customTextStyle(
                                      fontSize: Sizes.default12, color: ColorsUtils.color797),
                                ),
                              )
                            ],
                          ),
                        ),
                      )
                    ],
                  ),
                  Container(
                    margin: const EdgeInsets.only(top: Sizes.default25),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text(
                          '待入账总额',
                          style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                        ),
                        Text(
                          '407.89',
                          style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                        )
                      ],
                    ),
                  )
                ],
              ),
            ),
            Container(
              margin: const EdgeInsets.only(
                  left: Sizes.default20, right: Sizes.default20, top: Sizes.default20),
              decoration: boxDecoration,
              child: ListBody(
                children: [
                  InkWell(
                    onTap: () {
                      Get.toNamed(RouteGet.financeManagePayment);
                    },
                    child: Container(
                      height: Sizes.default80,
                      padding: const EdgeInsets.only(right: Sizes.default20),
                      child: Row(
                        children: [
                          Container(
                            width: 65,
                            alignment: Alignment.center,
                            child: ToolsUtils.getUrlImg(
                                'https://cdn7.axureshop.com/demo/1525603/images/财务管理/u1849.png',
                                width: 26,
                                height: 30),
                          ),
                          Expanded(
                              child: Container(
                                padding: const EdgeInsets.symmetric(vertical: Sizes.default10),
                                child: Column(
                                  children: [
                                    Container(
                                      height: Sizes.default30,
                                      alignment: Alignment.centerLeft,
                                      child: Row(
                                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                        children: [
                                          Text('共101单',
                                              style: StylesUtils.customTextStyle(
                                                  fontSize: Sizes.default15,
                                                  color: ColorsUtils.color333)),
                                          Text('140.47',
                                              style: StylesUtils.customTextStyle(
                                                  fontSize: Sizes.default15,
                                                  color: ColorsUtils.color333)),
                                        ],
                                      ),
                                    ),
                                    Container(
                                      height: Sizes.default30,
                                      alignment: Alignment.centerLeft,
                                      child: Row(
                                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                        children: [
                                          Text('2023-04-12',
                                              style: StylesUtils.customTextStyle(
                                                  fontSize: Sizes.default12,
                                                  color: ColorsUtils.color797)),
                                          Text('未入账',
                                              style: StylesUtils.customTextStyle(
                                                  fontSize: Sizes.default12,
                                                  color: ColorsUtils.colorFf0)),
                                        ],
                                      ),
                                    ),
                                  ],
                                ),
                              ))
                        ],
                      ),
                    ),
                  ),
                  Container(
                    height: Sizes.default80,
                    padding: const EdgeInsets.only(right: Sizes.default20),
                    child: Row(
                      children: [
                        Container(
                          width: 65,
                          alignment: Alignment.center,
                          child: ToolsUtils.getUrlImg(
                              'https://cdn7.axureshop.com/demo/1525603/images/财务管理/u1849.png',
                              width: 26,
                              height: 30),
                        ),
                        Expanded(
                            child: Container(
                          padding: const EdgeInsets.symmetric(vertical: Sizes.default10),
                          child: Column(
                            children: [
                              Container(
                                height: Sizes.default30,
                                alignment: Alignment.centerLeft,
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text('共101单',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default15,
                                            color: ColorsUtils.color333)),
                                    Text('140.47',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default15,
                                            color: ColorsUtils.color333)),
                                  ],
                                ),
                              ),
                              Container(
                                height: Sizes.default30,
                                alignment: Alignment.centerLeft,
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text('2023-04-12',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default12,
                                            color: ColorsUtils.color797)),
                                    Text('已入账',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default12,
                                            color: ColorsUtils.color797)),
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ))
                      ],
                    ),
                  ),
                  Container(
                    height: Sizes.default80,
                    padding: const EdgeInsets.only(right: Sizes.default20),
                    child: Row(
                      children: [
                        Container(
                          width: 65,
                          alignment: Alignment.center,
                          child: ToolsUtils.getUrlImg(
                              'https://cdn7.axureshop.com/demo/1525603/images/财务管理/u1849.png',
                              width: 26,
                              height: 30),
                        ),
                        Expanded(
                            child: Container(
                          padding: const EdgeInsets.symmetric(vertical: Sizes.default10),
                          child: Column(
                            children: [
                              Container(
                                height: Sizes.default30,
                                alignment: Alignment.centerLeft,
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text('共101单',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default15,
                                            color: ColorsUtils.color333)),
                                    Text('140.47',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default15,
                                            color: ColorsUtils.color333)),
                                  ],
                                ),
                              ),
                              Container(
                                height: Sizes.default30,
                                alignment: Alignment.centerLeft,
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text('2023-04-12',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default12,
                                            color: ColorsUtils.color797)),
                                    Text('已入账',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default12,
                                            color: ColorsUtils.color797)),
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ))
                      ],
                    ),
                  ),
                  Container(
                    height: Sizes.default80,
                    padding: const EdgeInsets.only(right: Sizes.default20),
                    child: Row(
                      children: [
                        Container(
                          width: 65,
                          alignment: Alignment.center,
                          child: ToolsUtils.getUrlImg(
                              'https://cdn7.axureshop.com/demo/1525603/images/财务管理/u1849.png',
                              width: 26,
                              height: 30),
                        ),
                        Expanded(
                            child: Container(
                          padding: const EdgeInsets.symmetric(vertical: Sizes.default10),
                          child: Column(
                            children: [
                              Container(
                                height: Sizes.default30,
                                alignment: Alignment.centerLeft,
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text('共101单',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default15,
                                            color: ColorsUtils.color333)),
                                    Text('140.47',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default15,
                                            color: ColorsUtils.color333)),
                                  ],
                                ),
                              ),
                              Container(
                                height: Sizes.default30,
                                alignment: Alignment.centerLeft,
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text('2023-04-12',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default12,
                                            color: ColorsUtils.color797)),
                                    Text('已入账',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default12,
                                            color: ColorsUtils.color797)),
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ))
                      ],
                    ),
                  ),
                  Container(
                    height: Sizes.default80,
                    padding: const EdgeInsets.only(right: Sizes.default20),
                    child: Row(
                      children: [
                        Container(
                          width: 65,
                          alignment: Alignment.center,
                          child: ToolsUtils.getUrlImg(
                              'https://cdn7.axureshop.com/demo/1525603/images/财务管理/u1849.png',
                              width: 26,
                              height: 30),
                        ),
                        Expanded(
                            child: Container(
                          padding: const EdgeInsets.symmetric(vertical: Sizes.default10),
                          child: Column(
                            children: [
                              Container(
                                height: Sizes.default30,
                                alignment: Alignment.centerLeft,
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text('共101单',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default15,
                                            color: ColorsUtils.color333)),
                                    Text('140.47',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default15,
                                            color: ColorsUtils.color333)),
                                  ],
                                ),
                              ),
                              Container(
                                height: Sizes.default30,
                                alignment: Alignment.centerLeft,
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text('2023-04-12',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default12,
                                            color: ColorsUtils.color797)),
                                    Text('已入账',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default12,
                                            color: ColorsUtils.color797)),
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ))
                      ],
                    ),
                  ),
                  Container(
                    height: Sizes.default80,
                    padding: const EdgeInsets.only(right: Sizes.default20),
                    child: Row(
                      children: [
                        Container(
                          width: 65,
                          alignment: Alignment.center,
                          child: ToolsUtils.getUrlImg(
                              'https://cdn7.axureshop.com/demo/1525603/images/财务管理/u1849.png',
                              width: 26,
                              height: 30),
                        ),
                        Expanded(
                            child: Container(
                          padding: const EdgeInsets.symmetric(vertical: Sizes.default10),
                          child: Column(
                            children: [
                              Container(
                                height: Sizes.default30,
                                alignment: Alignment.centerLeft,
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text('共101单',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default15,
                                            color: ColorsUtils.color333)),
                                    Text('140.47',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default15,
                                            color: ColorsUtils.color333)),
                                  ],
                                ),
                              ),
                              Container(
                                height: Sizes.default30,
                                alignment: Alignment.centerLeft,
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text('2023-04-12',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default12,
                                            color: ColorsUtils.color797)),
                                    Text('已入账',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default12,
                                            color: ColorsUtils.color797)),
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ))
                      ],
                    ),
                  ),
                  Container(
                    height: Sizes.default80,
                    padding: const EdgeInsets.only(right: Sizes.default20),
                    child: Row(
                      children: [
                        Container(
                          width: 65,
                          alignment: Alignment.center,
                          child: ToolsUtils.getUrlImg(
                              'https://cdn7.axureshop.com/demo/1525603/images/财务管理/u1849.png',
                              width: 26,
                              height: 30),
                        ),
                        Expanded(
                            child: Container(
                          padding: const EdgeInsets.symmetric(vertical: Sizes.default10),
                          child: Column(
                            children: [
                              Container(
                                height: Sizes.default30,
                                alignment: Alignment.centerLeft,
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text('共101单',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default15,
                                            color: ColorsUtils.color333)),
                                    Text('140.47',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default15,
                                            color: ColorsUtils.color333)),
                                  ],
                                ),
                              ),
                              Container(
                                height: Sizes.default30,
                                alignment: Alignment.centerLeft,
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text('2023-04-12',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default12,
                                            color: ColorsUtils.color797)),
                                    Text('已入账',
                                        style: StylesUtils.customTextStyle(
                                            fontSize: Sizes.default12,
                                            color: ColorsUtils.color797)),
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ))
                      ],
                    ),
                  ),
                  Container(
                      height: 48,
                      alignment: Alignment.center,
                      decoration: BoxDecoration(
                          border: Border(
                              top: BorderSide(
                                  color: ColorsUtils.parseColorFromHexString('#D7D7D7')))),
                      child: TextButton(
                          onPressed: () {
                            Get.toNamed(RouteGet.financeManageProceed);
                          },
                          child: Text(
                            '查看全部收款',
                            style: StylesUtils.customTextStyle(
                                color: ColorsUtils.colorFf6, fontSize: Sizes.default15),
                          )))
                ],
              ),
            ),
            Container(
              padding: const EdgeInsets.all(Sizes.default20),
              alignment: Alignment.centerLeft,
              child: Text(
                '注意：由于订单异常或跨天结算等原因，结算中与实际入账金额可能会有误差，请以实际入账金额为准。',
                style: StylesUtils.customTextStyle(
                    fontSize: Sizes.default13, color: ColorsUtils.color797, lineHeight: 1.5),
              ),
            )
          ],
        ),
      ),
    );
  }

  BoxDecoration get boxDecoration {
    return BoxDecoration(
        color: Colors.white,
        border: Border.all(color: ColorsUtils.rgba(252, 252, 252, 1)),
        borderRadius: BorderRadius.circular(Sizes.default10));
  }
}

class _BottomClipper extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    var path = Path();

    ///第1个点
    path.lineTo(0, 0);

    ///第2个点
    path.lineTo(0, size.height - 50.0);
    var firstControlPoint = Offset(size.width / 2, size.height);
    var firstEdnPoint = Offset(size.width, size.height - 50.0);
    path.quadraticBezierTo(
        firstControlPoint.dx, firstControlPoint.dy, firstEdnPoint.dx, firstEdnPoint.dy);

    ///第3个点
    path.lineTo(size.width, size.height - 50.0);

    ///第4个点
    path.lineTo(size.width, 0);
    return path;
  }

  @override
  bool shouldReclip(CustomClipper<Path> oldClipper) {
    return false;
  }
}
